package org.web.accesscontrollist.sdk.dto;

import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

@Setter
@Getter
public class SaveAclDefinitionBatchDTO {

    /**
     * 操作员信息，上次修改记录的操作人员工号，唯一标识操作人员。用于鉴权，校验是否有写权限，不允许为空。
     */
    @NotNull(message = "operatorDTO can't be null. ")
    private OperatorDTO operatorDTO;

    /**
     * 绑定关系，AclUserResourceMappingDTO记录资源、角色、用户的绑定关系。
     */
    @NotNull(message = "aclResourceDefinitionDTOList can't be null.")
    @Size(min = 1, max = 2000, message = "一次更新数据数量超过2000条上限。")
    List<AclResourceDefinitionDTO> aclResourceDefinitionDTOList;

    public SaveAclDefinitionBatchDTO(OperatorDTO operatorDTO, List<AclResourceDefinitionDTO> aclResourceDefinitionDTOList) {
        this.operatorDTO = operatorDTO;
        this.aclResourceDefinitionDTOList = aclResourceDefinitionDTOList;
        // 构建对象的同时校验参数的合法性。
        AclResourceHelper.checkSaveAclResourceDefinitionBatch(this);
    }

}

